|
1
|
|
|
import { BaseEndpoint } from './baseEndpoint'; |
|
2
|
|
|
import { |
|
3
|
|
|
TrendingAllResponse, |
|
4
|
|
|
TrendingMovieResponse, |
|
5
|
|
|
TrendingPersonResponse, |
|
6
|
|
|
TrendingTVResponse, |
|
7
|
|
|
} from '../interfaces/trending'; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Trending Endpoint Class |
|
11
|
|
|
* @see https://developers.themoviedb.org/3/trending/get-trending |
|
12
|
|
|
*/ |
|
13
|
|
|
export class Trending extends BaseEndpoint { |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Get all trending items for a day |
|
17
|
|
|
* @return Promise<TrendingAllResponse> |
|
18
|
|
|
*/ |
|
19
|
|
|
public async allDaily(): Promise<TrendingAllResponse> { |
|
20
|
|
|
return this.allDry('day'); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Get all trending items for a week |
|
25
|
|
|
* @return Promise<TrendingAllResponse> |
|
26
|
|
|
*/ |
|
27
|
|
|
public async allWeekly(): Promise<TrendingAllResponse> { |
|
28
|
|
|
return this.allDry('week'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Get all trending movies for a day |
|
33
|
|
|
* @return Promise<TrendingMovieResponse> |
|
34
|
|
|
*/ |
|
35
|
|
|
public async moviesDaily(): Promise<TrendingMovieResponse> { |
|
36
|
|
|
return this.movieDry('day'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Get all trending movies for a week |
|
41
|
|
|
* @return Promise<TrendingMovieResponse> |
|
42
|
|
|
*/ |
|
43
|
|
|
public async moviesWeekly(): Promise<TrendingMovieResponse> { |
|
44
|
|
|
return this.movieDry('week'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Get all trending people for a day |
|
49
|
|
|
* @return Promise<TrendingPersonResponse> |
|
50
|
|
|
*/ |
|
51
|
|
|
public async peopleDaily(): Promise<TrendingPersonResponse> { |
|
52
|
|
|
return this.personDry('day'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Get all trending people for a week |
|
57
|
|
|
* @return Promise<TrendingPersonResponse> |
|
58
|
|
|
*/ |
|
59
|
|
|
public async peopleWeekly(): Promise<TrendingPersonResponse> { |
|
60
|
|
|
return this.personDry('week'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Get all trending TV Series for a day |
|
65
|
|
|
* @return Promise<TrendingTVResponse> |
|
66
|
|
|
*/ |
|
67
|
|
|
public async tvDaily(): Promise<TrendingTVResponse> { |
|
68
|
|
|
return this.tvDry('day'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Get all trending TV Series for a week |
|
73
|
|
|
* @return Promise<TrendingTVResponse> |
|
74
|
|
|
*/ |
|
75
|
|
|
public async tvWeekly(): Promise<TrendingTVResponse> { |
|
76
|
|
|
return this.tvDry('week'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Get list of all trending items for a given time slice |
|
81
|
|
|
* @param { string } timeSlice |
|
82
|
|
|
* @return Promise<TrendingAllResponse> |
|
83
|
|
|
*/ |
|
84
|
|
|
private async allDry(timeSlice: string): Promise<TrendingAllResponse> { |
|
85
|
|
|
return this.sendGetRequest(`trending/all/${timeSlice}`); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Get list of trending movies for a given time slice |
|
90
|
|
|
* @param { string } timeSlice |
|
91
|
|
|
* @return Promise<TrendingAllResponse> |
|
92
|
|
|
*/ |
|
93
|
|
|
private async movieDry(timeSlice: string): Promise<TrendingMovieResponse> { |
|
94
|
|
|
return this.sendGetRequest(`trending/movie/${timeSlice}`); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Get list of trending people for a given time slice |
|
99
|
|
|
* @param { string } timeSlice |
|
100
|
|
|
* @return Promise<TrendingPersonResponse> |
|
101
|
|
|
*/ |
|
102
|
|
|
private async personDry(timeSlice: string): Promise<TrendingPersonResponse> { |
|
103
|
|
|
return this.sendGetRequest(`trending/person/${timeSlice}`); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Get list of trending tv series for a given time slice |
|
108
|
|
|
* @param { string } timeSlice |
|
109
|
|
|
* @return Promise<TrendingTVResponse> |
|
110
|
|
|
*/ |
|
111
|
|
|
private async tvDry(timeSlice: string): Promise<TrendingTVResponse> { |
|
112
|
|
|
return this.sendGetRequest(`trending/tv/${timeSlice}`); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
|